var g, _extends = Object.assign || function(t) {
    for (var a = 1; a < arguments.length; a++) {
        var e, o = arguments[a];
        for (e in o) Object.prototype.hasOwnProperty.call(o, e) && (t[e] = o[e]);
    }
    return t;
}, _tools = require("../../../utils/tools.js"), app = getApp(), page = app.page, request = app.util.request, route = app.route;

function getTxSet() {
    request({
        url: "MLawTxSet",
        success: function(t) {
            g.setData(_extends({}, t));
        }
    });
}

function toast(t) {
    wx.showToast({
        icon: "none",
        title: t
    });
}

page({
    data: {
        tx_bg: app.srcRoot + "tx_bg.png",
        checked: 1,
        value: "0.0"
    },
    onLoad: function(t) {
        (g = this).setData({
            value: app.m || 0
        }, function() {
            app.m = "";
        }), getTxSet();
    },
    check: function(t) {
        (0, _tools.subscribe)("LAWYER");
        t = t.currentTarget.dataset.type;
        g.setData({
            checked: t
        });
    },
    allMoney: function(t) {
        (0, _tools.subscribe)("LAWYER"), t = parseFloat(g.data.value || 0), g.setData({
            money: g.data.value,
            shdz: parseFloat(t * (100 - g.data.commission) / 100).toFixed(2)
        });
    },
    input: function(t) {
        t = parseFloat(t.detail.value || 0), g.setData({
            shdz: parseFloat(t * (100 - this.data.commission) / 100).toFixed(2)
        });
    },
    submit: function(t) {
        (0, _tools.subscribe)("LAWYER");
        var a = t.detail.value.name || "", e = t.detail.value.account || "", o = parseFloat(t.detail.value.money), s = parseInt(g.data.checked), t = parseFloat(g.data.value);
        !o || t < o || o < parseFloat(g.data.minimoney) || o > parseFloat(g.data.maxmoney) && 0 < parseFloat(g.data.maxmoney) ? toast("提现金额错误") : a && e || 1 == s ? request({
            url: "MLawTx",
            data: {
                tx_name: a,
                tx_zhanghao: e,
                tx_type: s,
                money: o,
                user_id: app.userInfo.id || wx.getStorageSync("userInfo").id
            },
            success: function(t) {
                1 == t ? (app.item = {
                    title: "提交成功",
                    content: "请耐心等待平台审核",
                    img: "pay_ok",
                    button: [ {
                        title: "返回首页",
                        url: "loading",
                        type: "reLaunch"
                    }, {
                        title: "返回钱包",
                        type: "navigateBack",
                        delta: 1
                    } ]
                }, route({
                    type: "redirect",
                    url: "result"
                })) : toast("错误:" + t);
            }
        }) : toast("请填写账户信息");
    }
});